home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / grafica / ghostscript / 5.10 / data / prfont.ps < prev    next >
Text File  |  1996-12-23  |  4KB  |  154 lines

  1. %!
  2. %%Creator: Eric Gisin <egisin@waterloo.csnet>
  3. %%Title: Print font catalog
  4. % Copyright (c) 1986 Eric Gisin
  5. % Copyright (C) 1992 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  6. %   Modified to print all 256 encoded characters.
  7. % Copyright (C) 1993 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  8. %   Modified to print unencoded characters.
  9. % Copyright (C) 1994 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  10. %   Modified to always create 256-element Encoding vectors.
  11. % Copyright (C) 1995 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  12. %   Modified to print more than 128 unencoded characters.
  13. % Copyright (C) 1996 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  14. %   Modified to leave a slightly wider left margin, because many H-P
  15. %     printers can't print in the leftmost 1/4" of the page.
  16. %   Modified to print unencoded characters in any font that has CharStrings.
  17.  
  18. % Example usages at bottom of file
  19.  
  20. /#copies 1 def
  21. /min { 2 copy gt { exch } if pop } bind def
  22.  
  23. /T6 /Times-Roman findfont 6 scalefont def
  24. /Temp 64 string def
  25. /Inch {72 mul} def
  26. /Base 16 def    % char code output base
  27. /TempEncoding [ 256 { /.notdef } repeat ] def
  28.  
  29. % do single character of page
  30. % output to rectangle ll=(0,-24) ur=(36,24)
  31. /DoChar {
  32.   /C exch def
  33.   /S (_) dup 0 C put def
  34.   /N F /Encoding get C get def
  35.  
  36.   % print code name, width and char name
  37.   /W F setfont S stringwidth pop def
  38.   T6 setfont
  39.   N /.notdef ne {0 -20 moveto N Temp cvs show} if
  40.   0 -12 moveto C Base Temp cvrs show (  ) show
  41.   W 0.0005 add Temp cvs 0 5 getinterval show
  42.  
  43.   % print char with reference lines
  44.   N /.notdef ne {
  45.     3 0 translate
  46.     0 0 moveto F24 setfont N glyphshow
  47.     /W S stringwidth pop def
  48.     0 -6 moveto 0 24 lineto
  49.     W -6 moveto W 24 lineto
  50.     -3 0 moveto W 3 add 0 lineto
  51.     0 setlinewidth stroke
  52.   } if
  53. } def
  54.  
  55. % print page title
  56. /DoTitle {
  57.   /Times-Roman findfont 18 scalefont setfont
  58.   36 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
  59. } def
  60.  
  61. % print one block of characters
  62. /DoBlock {    % firstcode lastcode
  63.   /FirstCode 2 index def
  64.   1 exch {
  65.     /I exch def
  66.     /Xn I FirstCode sub 16 mod def /Yn I FirstCode sub 16 idiv def
  67.     gsave
  68.     Xn 35 mul 24 add Yn -56 mul 9.5 Inch add translate
  69.     I DoChar
  70.     grestore
  71.   } for
  72. } def
  73.  
  74. % print a line of character
  75. /DoLine {    % firstcode lastcode
  76.   1 exch { (_) dup 0 3 index put show pop } for
  77. } def
  78.  
  79. % print font sample page
  80. /DoFont {
  81.   /FName exch def    % font name
  82.   /F FName findfont def
  83.   /F24 F 24 scalefont def
  84.   /Line0 96 string def
  85.   /Line1 96 string def
  86.  
  87.     % Display the first 128 encoded characters.
  88.  
  89.   DoTitle (, characters 0-127) show
  90.   0 127 DoBlock
  91.   F 10 scalefont setfont
  92.   36 2.0 Inch moveto 0 63 DoLine
  93.   36 1.5 Inch moveto 64 127 DoLine
  94.   showpage
  95.  
  96.     % Display the second 128 encoded characters.
  97.  
  98.   DoTitle (, characters 128-255) show
  99.   128 255 DoBlock
  100.   F 10 scalefont setfont
  101.   36 2.0 Inch moveto 128 191 DoLine
  102.   36 1.5 Inch moveto 192 255 DoLine
  103.   showpage
  104.  
  105.   F /CharStrings known
  106.    {
  107.         % Find and display the unencoded characters.
  108.  
  109.     /Encoded F /Encoding get length dict def
  110.     F /Encoding get { true Encoded 3 1 roll put } forall
  111.     /Unencoded [ F /CharStrings get
  112.      { pop dup Encoded exch known { pop } if }
  113.     forall ] def
  114.     /Count Unencoded length def
  115.  
  116.         % Print the unencoded characters in blocks of 128.
  117.  
  118.     0 128 Unencoded length 1 sub
  119.      { dup 128 add Unencoded length min 1 index sub
  120.        Unencoded 3 1 roll getinterval TempEncoding copy
  121.        /BlockEncoding exch def
  122.        /BlockCount BlockEncoding length def
  123.        save
  124.        F length dict F
  125.         { 1 index /FID eq { pop pop } { 2 index 3 1 roll put } ifelse }
  126.        forall dup /Encoding TempEncoding put
  127.        /* exch definefont
  128.        /F exch def
  129.        /F24 F 24 scalefont def
  130.  
  131.        DoTitle (, unencoded characters) show
  132.        0 BlockCount 1 sub DoBlock
  133.        F 10 scalefont setfont
  134.        36 2.0 Inch moveto 0 BlockCount 64 min 1 sub DoLine
  135.        BlockCount 64 gt
  136.         { 36 1.5 Inch moveto 64 BlockCount 128 min 1 sub DoLine
  137.         }
  138.        if
  139.        showpage
  140.        restore
  141.      } for
  142.  
  143.    }
  144.   if
  145.  
  146. } def
  147.  
  148. % Do font samples
  149. % /Times-Roman DoFont            % Test (less than a minute)
  150. % /Hershey-Gothic-English DoFont    % Test (8 minutes)
  151.  
  152. % Do a complete catalog
  153. % FontDirectory {pop DoFont} forall    % All fonts (quite a long time)
  154.